<template>
	<view>
		<uni-popup ref="applicationRef" @maskClick="closePopup()">
			<view class="popup-bd">
				<view class="popup-title mt20">
					{{ `${actionDesc.title}` }}
					<uni-icons
						type="closeempty"
						class="popup-close"
						@click="closePopup()"
					></uni-icons>
				</view>
				<view class="popup-content" style="overflow-y: auto">
					<!-- 退回 -->
					<view v-if="action === 'recall'" class="mb10">
						<view class="mb30">
							<view class="mb20 recall-title">退回到</view>
							<view
								class="df jsb ac bd-bottom-f2 p10"
								@tap="openPopupRecall('recallTo')"
							>
								<view>
									<view
										v-if="
											recallToData &&
											recallToData.length > 0
										"
									>
										<text class="mr10">{{
											recallToData[0].label.nodeName
										}}</text>
										<text>{{
											recallToData[0].label.users
												.map((i) => i.name)
												.join(',')
										}}</text>
									</view>
									<view class="g9" v-else>请选择</view>
								</view>
								<uni-icons
									type="right"
									size="15"
									color="#ccc"
								></uni-icons>
							</view>
						</view>
						<view class="mb30">
							<view class="recall-title"
								>已处理完成节点（审批/办理）是否需重新处理</view
							>
							<view class="p10">
								<uni-data-checkbox
									v-model="reHandle"
									:localdata="recallOptions"
								></uni-data-checkbox>
							</view>
						</view>
						<view
							class="mb30"
							v-if="
								reHandle &&
								dealtRecallNodes &&
								dealtRecallNodes.length > 0
							"
						>
							<view class="mb20 recall-title"
								>请选择需要重新处理的节点</view
							>
							<view
								class="df jsb ac bd-bottom-f2 p10"
								@tap="openPopupRecall('newNode')"
							>
								<view
									v-if="
										dealtRecallData &&
										dealtRecallData.length > 0
									"
								>
									<view
										v-for="i in dealtRecallData"
										:key="i.nodeId"
									>
										<text class="mr10">{{
											i.label.nodeName
										}}</text>
										<text>{{
											i.label.users
												.map((i) => i.name)
												.join(',')
										}}</text>
									</view>
								</view>
								<view class="g9" v-else>请选择</view>
								<uni-icons
									type="right"
									size="15"
									color="#ccc"
								></uni-icons>
							</view>
						</view>
					</view>

					<!-- 转交 加签-->
					<view v-if="['transfer', 'add'].includes(action)">
						<view class="mb30">
							<view class="mb20 recall-title">{{
								action === 'transfer'
									? '转交给谁'
									: '加签审批人'
							}}</view>
							<view
								class="df jsb ac bd-bottom-f2 p10"
								@tap="openPopupRecall(action)"
							>
								<view
									:class="
										actionData.targetUser &&
										actionData.targetUser.length > 0
											? ''
											: 'g9'
									"
								>
									<view>{{
										actionData.targetUser &&
										actionData.targetUser.length > 0
											? actionData.targetUser[0].name
											: '请选择'
									}}</view>
								</view>
								<uni-icons
									type="right"
									size="15"
									color="#ccc"
								></uni-icons>
							</view>
						</view>
					</view>
					<!-- <view v-if="action === 'transfer' || action === 'beforeAdd' || action === 'afterAdd'" style="margin-bottom: 10px">
					    <view class="df ac">
							<text v-if="action === 'transfer'">转交给谁：</text>
							<text v-else>给谁加签</text>
							<view class="w70">
								<uni-data-select
								    v-model="actionData.targetUser"
								    :localdata="userList"
								    :clear="false">
								</uni-data-select>
							</view>
						</view>
					</view> -->

					<!-- 撤销 -->
					<view
						v-if="
							action === 'cancel' &&
							instance.status === 'COMPLETE'
						"
						class="cancel-warning"
						>审批已通过，如需撤销需填写理由提交后重新审核</view
					>
					<view class="mb20 f32 text-color">{{
						actionDesc.tip
					}}</view>
					<view class="box-b">
						<textarea
							class="textarea pct100"
							v-model="actionData.comment.text"
							placeholder-style="font-size:36rpx;color:#D9D9D9;"
							maxlength="255"
						>
						</textarea>
						<!-- 推荐回复 -->
						<view
							v-if="
								[
									'agree',
									'refuse',
									'comment',
									'audit',
								].includes(action)
							"
						>
							<view class="ga f28 mb10">推荐回复</view>
							<diy-tags
								@update="getTagList"
								:keyWordList="keyWordList"
								:selectType="'single'"
								:formatType="'reply'"
								@sumbit="sumbitKeyWord"
							>
							</diy-tags>
						</view>
					</view>
					<!-- 语音 -->
					<view class="mt20">
						<diy-record
							:context="content"
							@upload="getRecordFile"
							:type="'processAction'"
						></diy-record>
					</view>

					<!-- 签字 -->
					<view
						class="mb20 mt20 border-f2 border-r-10 pt20 pb20 pl10"
						v-if="
							(['agree', 'refuse'].includes(action) &&
								instance &&
								instance.settings &&
								instance.settings.sign) ||
							isSign
						"
					>
						<view class="f36">
							<text class="is-required">*</text>
							签字
						</view>
						<view @tap="openPopup" class="df jsb ac">
							<view v-if="!signatureUrl" class="b2 mt10"
								>请点击签名</view
							>
							<view v-else>
								<image
									style="
										width: 200rpx;
										height: 200rpx;
										transform: rotate(90deg);
									"
									:src="signatureUrl"
								></image>
							</view>
							<uni-icons
								type="right"
								size="36rpx"
								color="#999999"
							/>
						</view>
					</view>

					<!-- 图片附件 -->
					<view>
						<view class="flex-between mt20 mb20">
							<view
								v-for="item in uploadTypeList"
								:key="item.value"
								@tap="changeUpload(item)"
								class="upload-item"
							>
								<view class="flex-center">
									<image
										:src="item.icon"
										class="image-icon"
									></image>
									{{ item.text }}
								</view>
							</view>
						</view>
						<view class="df src-box">
							<view
								v-for="(src, index) in uploadList"
								:key="index"
								class="item"
							>
								<view class="item-bd box-s">
									<image
										v-if="src.type == 'image'"
										class="item-cont"
										:src="src.url"
										mode="aspectFill"
										@tap="previewImage(src.url, uploadList)"
									></image>
									<view
										v-if="src.type === 'file'"
										class="flex-column-item"
									>
										<view class="pb20">{{
											`${src.name
												.split('.')[0]
												.slice(0, 7)}.${
												src.name.split('.')[1]
											}`
										}}</view>
										<view>{{
											`${(src.size / 1024).toFixed(2)}KB`
										}}</view>
									</view>
									<view
										class="icon-del-row"
										@click="delMedia(index)"
									>
										<view class="icon-del-col"></view>
										<view
											class="icon-del-col rotate"
										></view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>

				<view class="popup-bottom df">
					<button class="reset-button w40" @tap="cancel()">
						取消
					</button>
					<button class="primary-button w40" @tap="submit()">
						{{
							['agree', 'refuse'].includes(action)
								? actionDesc.title
								: '确定'
						}}
					</button>
				</view>
			</view>
		</uni-popup>
		<uni-popup
			ref="signature"
			@maskClick="closeSignature()"
			catchtouchmove="true"
		>
			<view class="popup-bd">
				<view class="popup-title bd-bottom-e">
					请签字
					<uni-icons
						type="closeempty"
						size="40rpx"
						color="#666666"
						class="popup-close"
						@click="closeSignature()"
					></uni-icons>
				</view>
				<view class="popup-content" style="max-height: auto">
					<view
						v-if="isShowSignature"
						style="height: 100%; background: #fff"
					>
						<l-signature
							disableScroll
							backgroundColor="#fff"
							ref="signatureRef"
							:penColor="penColor"
							:penSize="penSize"
							:openSmooth="openSmooth"
							landscape="true"
						></l-signature>
					</view>
				</view>
				<view class="popup-bottom">
					<view class="btn1 btnBoxView" @tap="clearClick">重签</view>
					<view class="btn2 btnBoxView" @tap="overSign"
						>完成签名并提交</view
					>
				</view>
			</view>
		</uni-popup>
		<diy-selectStep
			:type="'single'"
			:show="isShowRecallTo"
			:title="'请选择退回到哪一步'"
			:localData="recallNodes"
			:value="recallToData"
			@close="closePopupRecall('recallTo')"
			@submit="submitRecallTo"
		/>
		<diy-selectStep
			:type="'multiple'"
			:show="dealtRecall"
			:title="'请选择需要重新处理的节点'"
			:localData="dealtRecallNodes"
			:value="dealtRecallData"
			@close="closePopupRecall('newNode')"
			@submit="submitNewNode"
		/>
		<org-pick
			:show="transferShow"
			title="转交"
			@close="closePopupRecall('transfer')"
			:type="'user'"
			:selected="actionData.targetUser"
			@submit="submitTransfer"
		></org-pick>

		<org-pick
			:show="addShow"
			title="加签"
			@close="closePopupRecall('add')"
			:type="'user'"
			:selected="actionData.targetUser"
			@submit="submitAdd"
		></org-pick>
	</view>
</template>
<script>
import diyTags from '@/subPackagesIndex/components/diy-tags/diy-tags.vue'
import diyRecord from '@/subPackagesIndex/components/diy-record/diy-record.vue'
import diySelectStep from '@/subPackagesIndex/components/diy-selectStep/diy-selectStep.vue'
import orgPick from '@/subPackagesIndex/components/orgPick/orgPick.vue'
import {
	startProcess,
	getUserDepts,
} from '@/subPackagesIndex/pages/index/approval/launch/apis/design.js'
export default {
	components: {
		diyTags,
		diyRecord,
		diySelectStep,
		orgPick,
	},
	props: {
		isShow: {
			type: Boolean,
			default: false,
		},
		action: {
			type: String,
			default: 'agree',
		},
		instance: {
			type: Object,
			required: true,
		},
		// showSign:{
		//   type: Boolean,
		//   default: false
		// },
		activeTasks: {
			type: Array,
			default: () => {
				return []
			},
		},
		cancelActiveTasks: {
			type: Array,
			default: () => {
				return []
			},
		},
		auditTasks: {
			type: Array,
			default: () => {
				return []
			},
		},
		actionDesc: {
			type: Object,
			default: () => {
				return {}
			},
		},
		formData: {
			type: Object,
			default: () => {
				return {}
			},
		},
		isSign: {
			type: Boolean,
			default: false,
		},
	},
	data() {
		return {
			actionData: {
				taskId: null,
				signature: '',
				targetNode: null,
				targetUser: null,
				comment: {
					text: '',
					attachments: [],
					signature: '',
				},
			},
			content: '',
			fileValList: [],
			voliceList: [],
			userList: [],
			keyWordList: [],
			mediaFiles: [],
			penColor: 'balck',
			penSize: 10,
			openSmooth: true,
			signatureUrl: '',
			isShowSignature: false,
			uploadTypeList: [
				{
					text: '上传图片',
					value: 'image',
					icon: 'https://yilife-oss-dev-public.oss-cn-hangzhou.aliyuncs.com/34/130595/ORG/e6w7eb6rpwdeusnr3ey8q2839.png',
				},
				{
					text: '上传附件',
					value: 'file',
					icon: 'https://yilife-oss-dev-public.oss-cn-hangzhou.aliyuncs.com/34/130595/ORG/xh6qekraqf5xaun7mlrkkbogh.png',
				},
			],
			uploadList: [],
			userDepts: [],
			userDeptId: '',
			reHandle: 1,
			recallOptions: [
				{ value: 1, text: '是' },
				{ value: 0, text: '否' },
			],
			isShowRecallTo: false,
			dealtRecall: false,
			transferShow: false,
			addShow: false,
			recallNodes: [],
			recallToData: [],
			dealtRecallData: [],
			dealtRecallNodes: [],
		}
	},
	methods: {
		previewImage(url, list) {
			const pics = list
				.filter((i) => i.type === 'image')
				.map((imgItem) => imgItem.url)
			uni.previewImage({
				current: url,
				urls: pics,
			})
		},
		submitRecallTo(value) {
			this.recallToData = value
			const nodeIndex = this.recallNodes.findIndex(
				(item) => item.label.nodeId === value[0].label.nodeId
			)
			this.dealtRecallNodes = this.recallNodes.slice(
				nodeIndex + 1,
				this.recallNodes.length
			)
			if (this.dealtRecallNodes && this.dealtRecallNodes.length === 0) {
				this.recallOptions = this.recallOptions.map((i) => {
					return {
						...i,
						disable: true,
					}
				})
			} else {
				this.recallOptions = this.recallOptions.map((i) => {
					return {
						...i,
						disable: false,
					}
				})
			}
		},
		submitNewNode(value) {
			this.dealtRecallData = value
		},
		submitTransfer(value) {
			this.actionData.targetUser = value
		},
		submitAdd(value) {
			this.actionData.targetUser = value
		},
		closePopupRecall(type) {
			switch (type) {
				case 'recallTo':
					this.isShowRecallTo = false
					break
				case 'newNode':
					this.dealtRecall = false
					break
				case 'transfer':
					this.transferShow = false
					break
				case 'add':
					this.addShow = false
					break
			}
		},
		//打开退回节点
		openPopupRecall(type) {
			switch (type) {
				case 'recallTo':
					this.isShowRecallTo = true
					break
				case 'newNode':
					this.dealtRecall = true
					break
				case 'transfer':
					this.transferShow = true
					break
				case 'add':
					this.addShow = true
					break
			}
		},
		delMedia(i) {
			this.uploadList.splice(i, 1)
		},
		//文件提交上传
		addUpload(list) {
			let _that = this
			if (list.length) {
				list.forEach((item, index) => {
					//这里之所以循环一个一个上传是因为，我是用于小程序端的，目前uniapp不支持微信小程序以文件列表形式上传，
					uni.uploadFile({
						url:
							getApp().globalData.uploadDomain +
							'oss-web/oss/upload/file?asyn=false',
						filePath: item.tempFilePath,
						name: 'file',
						header: {
							tenantId: uni.getStorageSync('orgId'),
							Authorization: uni.getStorageSync('token'),
							reqChannel: getApp().globalData.reqChannel,
						},
						success: (uploadFileRes) => {
							let res = JSON.parse(uploadFileRes.data)
							if (res.success) {
								let data = res.data
								this.uploadList.push({ ...item, ...data })
							} else {
								uni.showToast({
									title: res.message
										? res.message
										: '上传失败~',
									icon: 'error',
								})
							}
						},
						fail(err) {
							console.log(err)
						},
					})
				})
			}
		},
		changeUpload(row) {
			const _that = this
			if (row.value === 'image') {
				uni.chooseMedia({
					mediaType: ['image'],
					success: function (res) {
						const list = res.tempFiles.map((i) => {
							return {
								...i,
								type: 'image',
								isImage: true,
								fileType: 1,
							}
						})
						_that.addUpload(list)
					},
				})
			} else {
				wx.chooseMessageFile({
					type: 'file',
					success(res) {
						const list = res.tempFiles.map((i) => {
							return {
								...i,
								tempFilePath: i.path,
								type: 'file',
								isImage: false,
								fileType: 4,
							}
						})
						_that.addUpload(list)
					},
				})
			}
		},
		openPopup() {
			this.isShowSignature = true
			this.$refs.signature.open('bottom')
		},
		closeSignature() {
			this.isShowSignature = false
			this.$refs.signature.close()
		},
		clearClick() {
			this.$refs.signatureRef.clear()
		},
		overSign() {
			this.$refs.signatureRef.canvasToTempFilePath({
				success: (res) => {
					// 是否为空画板 无签名
					// 生成图片的临时路径
					// H5 生成的是base64
					// this.url = res.tempFilePath
					// 将图片保存至阿里云
					uni.uploadFile({
						url:
							getApp().globalData.uploadDomain +
							'oss-web/oss/upload/file?asyn=false',
						filePath: res.tempFilePath,
						name: 'file',
						header: {
							tenantId: uni.getStorageSync('orgId'),
							Authorization: uni.getStorageSync('token'),
							reqChannel: getApp().globalData.reqChannel,
						},
						success: (uploadFileRes) => {
							let data = JSON.parse(uploadFileRes.data).data
							this.signatureUrl = data.url
							this.closeSignature()
						},
						fail() {
							this.closeSignature()
							uni.showToast({
								title: '签名提交失败~',
								icon: 'error',
							})
						},
					})
				},
			})
		},
		sumbitKeyWord(value) {
			this.actionData.comment.text =
				this.actionData.comment.text + value.tagName
		},

		getRecordFile(volice) {
			this.voliceList = [
				{
					name: '语音',
					isImage: false,
					url: volice.remark,
					fileType: 2,
					voiceDuration: volice.time,
					voiceText: volice.voiceText,
				},
			]
		},
		getEnableRecallNodes() {
			this.$request
				.request('wflow/wflow/process/task/recall/nodes', {
					data: {
						instanceId: this.instance.instanceId,
						taskId: this.getTask(),
					},
				})
				.then((rsp) => {
					this.recallNodes = rsp.map((item) => {
						return {
							value: item.nodeId,
							label: item,
						}
					})
				})
				.catch((err) => {
					uni.showToast({
						title: '获取可回退节点失败',
						icon: 'error',
					})
				})
		},

		// getUserList(){
		// 	this.$request.request('wflow/wflow/user/queryByPage', {
		// 		method:'post',
		// 		data: {
		// 			pageIndex: 1,
		// 			pageSize: 300,
		// 			type: "user"
		// 		}
		// 	}).then(res=>{
		// 		if(res.success){
		// 			this.userList=res.data.data.map(item=>{
		// 				return {
		// 					value:item.id,
		// 					text:item.name
		// 				}
		// 			})
		// 		}
		// 	})
		// },

		getTask() {
			if (this.actionData.taskId) {
				return this.actionData.taskId
			} else if (this.cancelActiveTasks.length > 0) {
				return this.cancelActiveTasks[0].taskId
			} else if (this.activeTasks.length > 0) {
				return this.activeTasks[0].taskId
			} else if (this.action === 'cancel') {
				const pg = this.instance.progress || []
				for (let i = 0; i < pg.length; i++) {
					if (pg[i].users) {
						for (let j = 0; j < pg[i].users.length; j++) {
							if (!pg[i].users[j].finishTime) {
								return pg[i].users[j].taskId
							}
						}
					} else {
						if (!pg[i].finishTime) {
							return pg[i].taskId
						}
					}
				}
			}
			return null
		},
		closePopup() {
			this.$emit('close')
		},
		cancel() {
			this.$emit('close')
		},
		submit() {
			if (
				this.action === 'cancel' &&
				this.instance.status === 'COMPLETE'
			) {
				const startParams = {
					isCancel: 1,
					originalProcessInstanceId: this.instance.instanceId,
					deptId: this.userDeptId,
					formData: this.instance.formData,
					processUsers: {},
					comment: {
						text: this.actionData.comment.text,
						attachments:
							this.voliceList &&
							this.voliceList.length > 0 &&
							this.voliceList[0].url
								? this.uploadList.concat(this.voliceList)
								: this.uploadList,
						signature: this.signatureUrl,
					},
				}
				startProcess(this.instance.processDefId, startParams)
					.then(() => {
						uni.showToast({
							title: '处理任务成功',
							icon: 'success',
						})
						setTimeout(function () {
							// uni.navigateTo({
							// 	url:`/subPackagesIndex/pages/index/approval/index?pagePath=approvalCenter`
							// })
							uni.navigateBack({
								delta: 1,
								fail() {
									console.log(111)
									uni.switchTab({
										url: '/pages/index/index',
									})
								},
							})
						}, 1500)
					})
					.catch(() => {
						console.log('失败')
					})
			} else {
				if (
					(this.instance.settings.sign || this.isSign) &&
					!this.signatureUrl &&
					this.action === 'agree'
				) {
					uni.showToast({
						title: '务必请签字',
						icon: 'none',
					})
					return
				}
				if (
					this.auditTasks.length > 0 &&
					this.auditTasks[0].requiredItem.length > 0
				) {
					if (
						!this.actionData.comment.text &&
						this.auditTasks[0].requiredItem.includes('content') &&
						this.action === 'audit'
					) {
						uni.showToast({
							title: '请输入办理意见',
							icon: 'none',
						})
						return
					}
					if (
						((this.uploadList && this.uploadList.length === 0) ||
							this.uploadList.filter((i) => i.type === 'image')
								.length === 0) &&
						this.auditTasks[0].requiredItem.includes('image') &&
						this.action === 'audit'
					) {
						uni.showToast({
							title: '请上传图片',
							icon: 'none',
						})
						return
					}
					if (
						((this.uploadList && this.uploadList.length === 0) ||
							this.uploadList.filter((i) => i.type === 'file')
								.length === 0) &&
						this.auditTasks[0].requiredItem.includes(
							'attachment'
						) &&
						this.action === 'audit'
					) {
						uni.showToast({
							title: '请上传附件',
							icon: 'none',
						})
						return
					}
				}
				if (
					(this.action === 'add' || this.action === 'transfer') &&
					!this.actionData.targetUser
				) {
					uni.showToast({
						title: '请设置人员',
						icon: 'error',
					})
					return
				} else if (
					this.action === 'recall' &&
					this.recallToData &&
					this.recallToData.length === 0
				) {
					uni.showToast({
						title: '请选择回退到哪个节点',
						icon: 'none',
					})
					return
				} else if (
					this.action === 'recall' &&
					this.reHandle &&
					this.dealtRecallNodes &&
					this.dealtRecallNodes.length > 0 &&
					this.dealtRecallData &&
					this.dealtRecallData.length === 0
				) {
					uni.showToast({
						title: '请选择重新处理的节点',
						icon: 'none',
					})
					return
				}
				let params = {
					instanceId: this.instance.instanceId,
					taskId: this.getTask(),
					comment: {
						text: this.actionData.comment.text,
						attachments:
							this.voliceList &&
							this.voliceList.length > 0 &&
							this.voliceList[0].url
								? this.uploadList.concat(this.voliceList)
								: this.uploadList,
						signature: this.signatureUrl,
					},
					formData: {
						...this.formData,
					},
					processType:
						this.instance &&
						this.instance.cancelProgress &&
						this.instance.cancelProgress.length > 0 &&
						['agree', 'refuse'].includes(this.action)
							? 'cancel_approve'
							: '',
					signature: null,
					action: this.action,
					targetNode:
						this.action === 'recall'
							? this.recallToData.map((item) => item.value)[0]
							: null,
					targetUser: this.actionData.targetUser
						? this.actionData.targetUser[0].id
						: null,
					reHandle:
						this.action === 'recall' ? Boolean(this.reHandle) : '',
					reHandleNodes:
						this.action === 'recall'
							? this.dealtRecallData.map((item) => item.value)
							: null,
					allHandleNodes:
						this.action === 'recall'
							? this.recallNodes.map((item) => item.value)
							: null,
				}
				this.$request
					.request('wflow/wflow/process/task/handler', {
						method: 'post',
						data: {
							...params,
						},
					})
					.then(() => {
						uni.showToast({
							title: '处理任务成功',
							icon: 'success',
						})
						setTimeout(function () {
							// uni.navigateTo({
							// 	url:`/subPackagesIndex/pages/index/approval/index?pagePath=approvalCenter`
							// })
							uni.navigateBack({
								delta: 1,
								fail() {
									console.log(2222)
									uni.switchTab({
										url: '/pages/index/index',
									})
								},
							})
						}, 1500)
					})
					.catch((err) => {
						uni.showToast({
							title: '处理任务失败',
							icon: 'error',
						})
					})
			}
		},
		getTagList(type) {
			switch (type) {
				case 7:
					// 同意
					this.keyWordList = [
						{ id: '1', tagName: '情况属实' },
						{ id: '2', tagName: '同意' },
						{ id: '3', tagName: '确认' },
						{ id: '4', tagName: 'ok' },
						{ id: '5', tagName: '已审核' },
						{ id: '6', tagName: '好的' },
					]
					break
				case 8:
					// 拒绝
					this.keyWordList = [
						{ id: '1', tagName: '不同意' },
						{ id: '2', tagName: '作废不同意' },
						{ id: '3', tagName: '拒绝' },
						{ id: '4', tagName: '取消' },
						{ id: '5', tagName: '作废' },
						{ id: '6', tagName: '重新提交' },
						{ id: '7', tagName: '未解决' },
						{ id: '8', tagName: '请核实' },
						{ id: '9', tagName: ' 请补充材料' },
					]
					break
				case 9:
					// 评论
					this.keyWordList = [
						{ id: '1', tagName: '已核对' },
						{ id: '2', tagName: '已阅' },
						{ id: '3', tagName: '收到' },
						{ id: '4', tagName: '合格' },
						{ id: '5', tagName: '情况属实' },
						{ id: '6', tagName: '确认' },
						{ id: '7', tagName: '已复核' },
						{ id: '8', tagName: '知悉' },
						{ id: '9', tagName: '辛苦了' },
					]
					break
				case 10:
					// 办理
					this.keyWordList = [
						{ id: '1', tagName: '已处理' },
						{ id: '2', tagName: '已办理' },
						{ id: '3', tagName: '已确认' },
						{ id: '4', tagName: '已核实' },
						{ id: '5', tagName: '无异议' },
						{ id: '6', tagName: '已修改' },
						{ id: '7', tagName: '已记录' },
						{ id: '8', tagName: '已操作' },
						{ id: '9', tagName: '已知晓' },
					]
					break
			}
			// this.$request.request('carer-platform/carer/businessTag/getBusinessTags', {
			// 	method:'post',
			// 	data: {
			// 		orgId:uni.getStorageSync('orgId'),
			// 		typeTags:[type],
			// 	}
			// }).then(res=>{
			// 	if(res.success){
			// 		this.keyWordList=res.data
			// 	}
			// })
		},
		getUserDept() {
			getUserDepts(uni.getStorageSync('userId'))
				.then((rsp) => {
					this.userDepts = rsp
					if (this.userDepts.length > 0) {
						this.userDeptId = this.userDepts[0].id
					}
				})
				.catch((err) => {
					uni.showModal({
						title: '提示',
						content: '获取用户部门信息失败',
					})
				})
		},
	},
	watch: {
		isShow(val) {
			if (val) {
				this.$refs.applicationRef.open('bottom')
				this.getUserDept()
				this.actionData.comment.text = ''
				this.actionData.targetUser = ''
				this.signatureUrl = ''
				this.uploadList = []
				if (['recall'].includes(this.action)) {
					this.getEnableRecallNodes()
				}
				// else if(['beforeAdd','afterAdd','transfer'].includes(this.action)){
				// 	this.getUserList()
				// }
				else if (this.action === 'agree') {
					this.getTagList(7)
				} else if (this.action === 'refuse') {
					this.getTagList(8)
				} else if (this.action === 'comment') {
					this.getTagList(9)
				} else if (this.action === 'audit') {
					this.getTagList(10)
				}
			} else {
				this.$refs.applicationRef.close()
			}
		},
	},
}
</script>

<style scoped lang="scss">
.textarea {
	width: 100%;
	height: 150rpx;
}
.box-b {
	border: 2rpx #f2f2f2 solid;
	padding: 30rpx;
	border-radius: 10rpx;
	border-bottom: 0;
	margin-bottom: -35rpx;
}
.b2 {
	color: #b2b2b2;
	font-size: 26rpx;
}
.btnBoxView {
	width: 50%;
	text-align: center;
	height: 50px;
	line-height: 50px;
	color: #ffffff;
}

.btnBoxView:active {
	background-color: #cccccc;
	color: #333333;
}

.btn1 {
	background-color: #ff8f58;
}

.btn2 {
	background-color: $primary-color;
}
.is-required {
	color: #dd524d;
	font-weight: bold;
}
.text-color {
	color: #101010;
}
.ga {
	color: #9a9a9a;
}
.upload-item {
	border-radius: 4px 4px 4px 4px;
	color: rgba(108, 108, 108, 1);
	font-size: 30rpx;
	text-align: center;
	font-family: PingFang SC;
	border: 1px solid rgba(239, 239, 239, 1);
	padding: 10rpx 5rpx;
	width: 45%;
}
.active-upload-item {
	background-color: rgba(241, 248, 255, 1);
	border: 0;
}
.image-icon {
	width: 35rpx;
	height: 35rpx;
	margin-right: 10rpx;
}
.src-box {
	flex-wrap: wrap;
}

.item {
	width: 33.3%;
	height: 0;
	padding-top: 33.33%;
	position: relative;
	box-sizing: border-box;
}
.item-bd {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 10rpx;
}

.item-cont {
	width: 100%;
	height: 100%;
}

.box-s {
	border: 2rpx solid #ccc;
	flex-direction: column;
}

.text-box {
	display: flex;
	flex-direction: column;
	align-items: center;
	font-size: 32rpx;
	line-height: 40px;
}

.icon-del-row {
	display: flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	top: 0;
	right: 0;
	height: 52rpx;
	width: 52rpx;
	border-radius: 50%;
	background-color: rgba(0, 0, 0, 0.5);
	z-index: 2;
	-webkit-transform: rotate(-45deg);
	transform: rotate(-45deg);
}

.icon-del-col {
	width: 15px;
	height: 2px;
	background-color: #fff;
	border-radius: 2px;
}
.rotate {
	position: absolute;
	-webkit-transform: rotate(90deg);
	transform: rotate(90deg);
}
.flex-column-item {
	font-size: 28rpx;
	color: #9a9a9a;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 0 10rpx;
}
.cancel-warning {
	color: #888888;
	font-size: 30rpx;
	margin: 20rpx 0;
	text-align: center;
}
.recall-title {
	font-size: 32rpx;
}
.recall-title::before {
	content: '*';
	width: 20rpx;
	height: 20rpx;
	color: #bd3124;
}
.popup-content {
	padding: 20rpx 30rpx;
}
</style>
